﻿Imports System.ComponentModel

Public Class CClavesOp
    Implements INotifyPropertyChanged

    Private _Mercado As String
    Private _TipoInversion As String
    Private _TipoTransaccion As String
    Private _TipoOperacion As String
    Private _InversionCovafsys As String
    Private _TransaccionCovafsys As String
    Private _DescripcionCovafsys As String
    Private _Comision As String
    Private _Impuesto As String
    Private _Calcular As String
    Private _blnEsEditableNuevo As Boolean
    
    Private _columnas(9) As Object

    Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged

    Private Sub NotificarCambio(ByVal propname As String)
        RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propname))
    End Sub

    Public Sub New()
        _Mercado = ""
        _TipoInversion = ""
        _TipoTransaccion = ""
        _TipoOperacion = ""
        _InversionCovafsys = ""
        _TransaccionCovafsys = ""
        _DescripcionCovafsys = ""
        _Comision = "0.00"
        _Impuesto = "0.00"
        _Calcular = ""
        _blnEsEditableNuevo = False


        Columnas(0) = _Mercado
        Columnas(1) = _TipoInversion
        Columnas(2) = _TipoTransaccion
        Columnas(3) = _TipoOperacion
        Columnas(4) = _InversionCovafsys
        Columnas(5) = _TransaccionCovafsys
        Columnas(6) = _DescripcionCovafsys
        Columnas(7) = _Comision
        Columnas(8) = _Impuesto
        Columnas(9) = _Calcular
    End Sub

    Default Property Columnas(ByVal index As Integer) As String
        Get
            Return _columnas(index)
        End Get
        Set(ByVal value As String)

            Try
                Select Case index
                    Case 0
                        Me.Mercado = value
                        NotificarCambio("Mercado")
                    Case 1
                        Me.TipoInversion = value
                        NotificarCambio("TipoInversion")
                    Case 2
                        Me.TipoTransaccion = value
                        NotificarCambio("TipoTransaccion")
                    Case 3
                        Me.TipoOperacion = value
                        NotificarCambio("TipoOperacion")
                    Case 4
                        Me.InversionCovafsys = value
                        NotificarCambio("InversionCovafsys")
                    Case 5
                        Me.TransaccionCovafsys = value
                        NotificarCambio("TransaccionCovafsys")
                    Case 6
                        Me.DescripcionCovafsys = value
                        NotificarCambio("DescripcionCovafsys")
                    Case 7
                        Me.Comision = value
                        NotificarCambio("Comision")
                    Case 8
                        Me.Impuesto = value
                        NotificarCambio("Impuesto")
                    Case 9
                        Me.Calcular = value
                        NotificarCambio("Calcular")
                End Select

            Catch ex As Exception
                Throw ex
            End Try

        End Set
    End Property

    Public Shared Function ValorInicalColumna(ByVal index As Integer) As Object
        Select Case index
            Case 0
                Return ""
            Case 1
                Return ""
            Case 2
                Return ""
            Case 3
                Return ""
            Case 4
                Return ""
            Case 5
                Return ""
            Case 6
                Return ""
            Case 7
                Return ""
            Case 8
                Return ""
            Case 9
                Return ""
            Case Else
                Return Nothing
        End Select
    End Function

    Public Shared Function IndexColumna(ByVal campo As String) As Integer
        Select Case campo
            Case "Mercado"
                Return 0
            Case "TipoInversion"
                Return 1
            Case "TipoTransaccion"
                Return 2
            Case "TipoOperacion"
                Return 3
            Case "InversionCovafsys"
                Return 4
            Case "TransaccionCovafsys"
                Return 5
            Case "DescripcionCovafsys"
                Return 6
            Case "Comision"
                Return 7
            Case "Impuesto"
                Return 8
            Case "Calcular"
                Return 9
            Case Else
                Return Nothing
        End Select
    End Function

    Public Property Mercado As String
        Get
            Return _Mercado
        End Get
        Set(ByVal value As String)
            value = value.Trim
            If value.Length > 10 Then
                value = value.Substring(1, 10)
            End If
            _Mercado = value
            _columnas(0) = _Mercado
            NotificarCambio("Mercado")
        End Set
    End Property

    Public Property TipoInversion As String
        Get
            Return _TipoInversion
        End Get
        Set(ByVal value As String)
            value = value.Trim
            If value.Length > 30 Then
                value = value.Substring(1, 30)
            End If
            _TipoInversion = value
            _columnas(1) = _TipoInversion
            NotificarCambio("TipoInversion")
        End Set
    End Property

    Public Property TipoTransaccion As String
        Get
            Return _TipoTransaccion
        End Get
        Set(ByVal value As String)
            value = value.Trim
            If value.Length > 10 Then
                value = value.Substring(1, 10)
            End If
            _TipoTransaccion = value
            _columnas(2) = _TipoTransaccion
            NotificarCambio("TipoTransaccion")
        End Set
    End Property

    Public Property TipoOperacion As String
        Get
            Return _TipoOperacion
        End Get
        Set(ByVal value As String)
            value = value.Trim
            If value.Length > 10 Then
                value = value.Substring(1, 10)
            End If
            _TipoOperacion = value
            _columnas(3) = _TipoOperacion
            NotificarCambio("TipoOperacion")
        End Set
    End Property

    Public Property InversionCovafsys As String
        Get
            Return _InversionCovafsys
        End Get
        Set(ByVal value As String)
            value = value.Trim
            If value.Length > 5 Then
                value = value.Substring(1, 5)
            End If
            _InversionCovafsys = value
            _columnas(4) = _InversionCovafsys
            NotificarCambio("InversionCovafsys")
        End Set
    End Property

    Public Property TransaccionCovafsys As String
        Get
            Return _TransaccionCovafsys
        End Get
        Set(ByVal value As String)
            value = value.Trim
            If value.Length > 5 Then
                value = value.Substring(1, 5)
            End If
            _TransaccionCovafsys = value
            _columnas(5) = _TransaccionCovafsys
            NotificarCambio("TransaccionCovafsys")
        End Set
    End Property

    Public Property DescripcionCovafsys As String
        Get
            Return _DescripcionCovafsys
        End Get
        Set(ByVal value As String)
            value = value.Trim
            If value.Length > 50 Then
                value = value.Substring(1, 50)
            End If
            _DescripcionCovafsys = value
            _columnas(6) = _DescripcionCovafsys
            NotificarCambio("DescripcionCovafsys")
        End Set
    End Property

    Public Property Comision As String
        Get
            Return _Comision
        End Get
        Set(ByVal value As String)
            _Comision = value
            _columnas(7) = _Comision
            NotificarCambio("Comision")
        End Set
    End Property

    Public Property Impuesto As String
        Get
            Return _Impuesto
        End Get
        Set(ByVal value As String)
            _Impuesto = value
            _columnas(8) = _Impuesto
            NotificarCambio("Impuesto")
        End Set
    End Property

    Public Property Calcular As String
        Get
            Return _Calcular
        End Get
        Set(ByVal value As String)
            _Calcular = value
            _columnas(9) = _Calcular
            NotificarCambio("Calcular")
        End Set
    End Property

    Public ReadOnly Property CalcularDB As String
        Get
            If _Calcular = "True" Or _Calcular = "1" Then
                CalcularDB = "1"
            Else
                CalcularDB = "0"
            End If
        End Get
    End Property

    Public Property EsEditableNuevo As Boolean
        Get
            Return _blnEsEditableNuevo
        End Get
        Set(ByVal value As Boolean)
            _blnEsEditableNuevo = value
        End Set
    End Property

    
End Class
